home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows 95 API Bible
/
Windows 95 API Bible 3 Disc Set.iso
/
Win32 API Bible Book 1 of 3.iso
/
chapte30
/
mydll.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-01-02
|
2KB
|
62 lines
#include <windows.h>
#include "mydll.h"
// Make this data shared among all
// all applications that use this DLL.
//....................................
#pragma data_seg( ".GLOBALS" )
int nProcessCount = 0;
int nThreadCount = 0;
#pragma data_seg()
BOOL WINAPI DLLMain( HINSTANCE hInstDLL, DWORD dwNotification, LPVOID lpReserved )
{
switch(dwNotification)
{
case DLL_PROCESS_ATTACH :
// DLL initialization code goes here. Formerly this
// would be in the LibMain function of a 16-bit DLL.
//..................................................
nProcessCount++;
return( TRUE );
case DLL_PROCESS_DETACH :
// DLL cleanup code goes here. Formerly this would
// be in the WEP function of a 16-bit DLL.
//................................................
nProcessCount--;
break;
case DLL_THREAD_ATTACH :
// Special initialization code for new threads goes here.
// This is so the DLL can "Thread Protect" itself.
//.......................................................
nThreadCount++;
break;
case DLL_THREAD_DETACH :
// Special cleanup code for threads goes here.
//............................................
nThreadCount--;
break;
}
return( FALSE );
}
DllAccess int AddNumbers( int a, int b )
{
return( a + b );
}
DllAccess int GetProcessCount()
{
return( nProcessCount );
}
DllAccess int GetThreadCount()
{
return( nThreadCount );
}